# account knows about its name, its parent "account", how it should handle
# debits and credits, and keeps track of its current balance. in pennies.
class Account
  attr_reader :account_name, :parent_account, :increase_type
  attr_accessor :current_balance

  def initialize(account_name, increase_type, parent_account)
    @account_name = account_name
    @increase_type = increase_type
    @parent_account = parent_account
    @current_balance = 0
  end
  
  # amount is in pennies, don't forget!
  def journal(entry_type, amount)
    if @increase_type == entry_type
      @current_balance += amount
    else
      @current_balance -= amount
    end
    @parent_account.journal(entry_type, amount) unless @parent_account.nil?
  end
end
